/*
* @Author: Administrator
* @Date:   2018-01-10 09:05:53
* @Last Modified by:   Administrator
* @Last Modified time: 2018-01-27 15:24:22
*/
const path = require('path')
const HtmlWepackPlugin = require('html-webpack-plugin')
const Webpack = require('webpack')

const config = {
  entry: {
    app: path.join(__dirname,'./client/app.jsx')
  },
  output: {
    filename: 'js/[name].js',
    path: path.join(__dirname,'dist'),
    publicPath: '/dist/'
  },
  module: {
    rules: [
      {
        test:/\.(js|jsx)$/,
        enforce:'pre',
        loader:'eslint-loader',
        exclude:path.join(__dirname,'./node_modules/')
      },
      {
        test:/\.(js|jsx)$/,
        loader:'babel-loader',
        exclude:path.join(__dirname,'./node_modules/')
      },
      {
        test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
        loader: 'url-loader?limit=20000&name=resource/[name].[ext]'
      },
    ]
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  plugins: [
    new HtmlWepackPlugin({
      filename: 'index.html',
      template: path.join(__dirname,'./client/index.html'),
      chunksSortMode:'dependency'
    }),
    new HtmlWepackPlugin({
      filename: 'server_template.ejs',
      template: '!!ejs-compiled-loader!'+path.join(__dirname,'./client/server_tempalte.ejs'),
      chunksSortMode:'dependency'
    }),
  ]
}
module.exports = config
